import React, { Component } from 'react';
// 导入路由组件
import {
  
  // 为了解决非组件页面跳转使用route
  Router,
  // BrowserRouter as Router,
  Route,
  Switch,
  Redirect,
} from 'react-router-dom';

// 导入页面组件
import history from './utils/history'
import Login from './pages/Login';
import Layout from './pages/Layout';
import AuthRoute from './components/AuthRoute';

//配置路由规则
export default class App extends Component {
  render() {
    return (
      // 将router包裹内容
      // 将Router组件替换之前的BrowserRouter 并自己传入history
      <Router history={history}>
        {/* <div>App</div> */}
        {/* 将Switch包裹路由规则 */}
        <Switch>
          {/* 重定向redirect */}
          {/* <Redirect from='/' to='/home' exact></Redirect> */}
          <Route path="/login" component={Login}></Route>
          {/* 将component写法改为render写法 */}
          {/* <Route path='/' component={Layout}></Route> */}
          <AuthRoute path="/" component={Layout}></AuthRoute>
        </Switch>
      </Router>
    );
  }
}

